tree-wide: Squash noncritical compiler warnings
authorColin Walters <walters@verbum.org>
Fri, 24 Feb 2017 14:33:20 +0000 (09:33 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 24 Feb 2017 17:08:27 +0000 (17:08 +0000)
Should fix everything from
<https://kojipkgs.fedoraproject.org//packages/ostree/2017.2/3.fc25/data/logs/x86_64/build.log>

Anything that uses autocleanups should *always* be initialized directly I think,
even if a few lines down we directly assign, since this way it's more robust
against refactoring.

And the `freopen()` warnings are right - IMO we should *always* check return
values.

Closes: #711
Approved by: jlebon

src/ostree/ostree-trivial-httpd.c
src/ostree/ot-builtin-admin.c
src/ostree/ot-builtin-remote.c
src/ostree/ot-main.c

index 72de8d790d8866e3d1dfdd2b9c665b7b7909a3e3..d6f0c4d4b9e4a726428fa7fa7b393bcd073a5bd5 100644 (file)
@@ -520,7 +520,7 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
         }
       else
         {
-          g_autoptr(GFile) log_file;
+          g_autoptr(GFile) log_file = NULL;
           GFileOutputStream* log_stream;
 
           log_file = g_file_new_for_path (opt_log);
@@ -601,9 +601,12 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
       if (setsid () < 0)
         err (1, "setsid");
       /* Daemonising: close stdout/stderr so $() et al work on us */
-      freopen("/dev/null", "r", stdin);
-      freopen("/dev/null", "w", stdout);
-      freopen("/dev/null", "w", stderr);
+      if (freopen("/dev/null", "r", stdin) == NULL)
+        err (1, "freopen");
+      if (freopen("/dev/null", "w", stdout) == NULL)
+        err (1, "freopen");
+      if (freopen("/dev/null", "w", stderr) == NULL)
+        err (1, "freopen");
     }
   else
     {
index 4760e532b1218fbf8c7ecbc69ff5108ed1e8db13..0d8290a8daf15263f1837f64b07e5228cb8a2c9d 100644 (file)
@@ -125,7 +125,7 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
   if (!subcommand->name)
     {
       g_autoptr(GOptionContext) context = NULL;
-      g_autofree char *help;
+      g_autofree char *help = NULL;
 
       context = ostree_admin_option_context_new_with_commands ();
 
index 4f01cac2b1779b704d9585c546ab185dc51b039f..f0667a421d1ffe7f3a914e48c0c6eb47a10f1cb3 100644 (file)
@@ -114,7 +114,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
   if (!subcommand->name)
     {
       g_autoptr(GOptionContext) context = NULL;
-      g_autofree char *help;
+      g_autofree char *help = NULL;
 
       context = remote_option_context_new_with_commands ();
 
index c6a2b6dd28faa110ec08c0dfbd5db50405c114a8..3484b18ee85d4df1fd3a2b4b769e793367f4d8a8 100644 (file)
@@ -171,7 +171,7 @@ ostree_run (int    argc,
   if (!command->fn)
     {
       g_autoptr(GOptionContext) context = NULL;
-      g_autofree char *help;
+      g_autofree char *help = NULL;
 
       context = ostree_option_context_new_with_commands (commands);